package leetcode.code0646;

import java.util.Arrays;

public class Soluion1 {

	public int findLongestChain(int[][] pairs) {
		Arrays.sort(pairs, (a, b) -> a[1] - b[1]);
		int last = Integer.MIN_VALUE, ans = 0;
		for (int[] pair : pairs) {
			if (pair[0] > last) {
				last = pair[1];
				ans++;
			}
		}
		return ans;
	}

}
